<include file="public@header" />
</head>
<body>
<style type="text/css">
	.aui_state_lock{
		top:50% !important;
		left: 50% !important;
		transform: translate(-50%,-50%);
	}
</style>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
	
			<li class="active" id="list"><a href="{:url('order/index')}">运营中心</a></li>
			<li><a href="{:url('order/addorder')}">添加</a></li>
			<!-- 	<li><a href="{:url('user/add')}">{:lang('ADMIN_USER_ADD')}</a></li> -->
		</ul>
		<form class="well form-inline margin-top-20" method="post" action="{:url('order/index')}">
		    空间名称:
			<input type="text" class="form-control" name="space_name" style="width: 140px;" value="" placeholder="请输入空间名称">
			业务员名称:
			<input type="text" class="form-control" name="salesname" style="width: 140px;" value="" placeholder="请输入业务员名称">
			<!-- 企业名称:
			<input type="text" class="form-control" name="commpany_name" style="width: 140px;" value="" placeholder="请输入业务员名称"> -->
			客户名称:
			<input type="text" class="form-control" name="customer_name" style="width: 140px;" value="{:session('customer_name')}" placeholder="请输入客户名称">
			<br/><br/>
			时间:
			<input type="text" class="form-control js-bootstrap-datetime" name="start_time"
			value="{$start_time|default=''}"
			style="width: 140px;" autocomplete="off">-
			<input type="text" class="form-control js-bootstrap-datetime" name="end_time"
			value="{$end_time|default=''}"
			style="width: 140px;" autocomplete="off"> &nbsp; &nbsp; 
			本期支付状态:
			<select class="form-control" name="status" style="width: 140px;">
				<option value='2' <if condition="$status eq 2">selected</if>>请选择</option>
				<option value="0" <if condition="$status eq 0">selected</if>>未支付</option>
				<option value="1" <if condition="$status eq 1">selected</if>>已支付</option>

			</select> &nbsp;&nbsp;
				订单状态:
			<select class="form-control" name="lease_status" style="width: 140px;">
				<option value='10' >请选择</option>
				<option value="0" <if condition="$lease_status eq 0">selected</if>>正常</option>
				<option value="1" <if condition="$lease_status eq 1">selected</if>>已退租</option>
				<option value="2" <if condition="$lease_status eq 2">selected</if>>到期</option>

			</select> &nbsp;&nbsp;	



			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="{:url('Order/index')}">清空</a>
		</form>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="1%">ID</th>
					<th width="5%">类型</th>
					<th width="6%">所属孵化器</th>
					<th width="5%">空间名</th>
					<th width="5%">客户名</th>
					<!-- <th width="8%">企业名</th> -->
					<th width="5%">单价</th>
					<th width="5%">数量</th>
					<th width="8%">服务费</th>
					<th width="8%">租金总额</th>
					<th width="6%">押金</th>
					<th width="9%">合同时间</th>
					<th width="9%">本期租金</th>
					<th width="8%">业务员</th>
					<th width="10%">订单状态</th>
					<th width="20%">操作</th>
				</tr>
			</thead>
			<tbody>
				<!-- 	<php>$user_statuses=array("0"=>lang('USER_STATUS_BLOCKED'),"1"=>lang('USER_STATUS_ACTIVATED'),"2"=>lang('USER_STATUS_UNVERIFIED'));</php> -->
				
				<foreach name="list" item="vo">
					<tr>
					    <input type="hidden" name="id" value="{$vo.id}">
						<td>{$vo.id}</td>
						<td><if condition="$vo['space_type'] eq 1"><?php echo get_park_type($vo['space_id']); ?><else/>场地</if></td>
						<td><?php echo get_incubator_name($vo['incubator_id']); ?></td>
						<td><a class="btn " href='{:url('Order/detailOrder',array('id'=>$vo.id))}'><?php echo get_space_name($vo['space_type'],$vo['space_id']); ?></a></td>
						<td> <?php echo get_customer_name($vo['customer_id']); ?></td>
						<!-- <td>{$vo.commpany_name} </td> -->
						<td>{$vo.price}<?php if($vo['space_type']==1){if(get_station_type($vo['space_id'])==1) {echo '元/平方米*天';}else{

						echo '元/个';}} else{ echo '元/次';} ?></td>
						<td>{$vo.amount}</td>
						<td>{$vo.service_price}</td>
						<td>{$vo.sum_price}</td>
						<td>{$vo.deposit_price}</td>
						<td><if condition="$vo['space_type'] eq 1"><?php echo date("Y-m-d",strtotime($vo['start_time'])).'---'.date("Y-m-d",strtotime($vo['end_time']));?><else/><?php echo date("Y-m-d H:i",strtotime($vo['start_time'])).'---'.date("Y-m-d H:i",strtotime($vo['end_time']));?></if></td>
						<td><if condition="$vo['current_price_status'] eq 0">未支付<else/>已支付</if></td>
						<td>{$vo.salesman}</td>
						<td>
						<switch name="$vo.lease_status">
							<case value="0">正常</case>
							<case value="1">退租</case>
							<case value="2">到期</case>
						</switch>
						</td>
						<td>
							<a class='edit' href='{:url('Order/editOrder',array('id'=>$vo.id))}'>编辑</a>
							
							<if condition="$vo['lease_status'] neq 1">
							|
							<a class='edit' href='{:url('Order/lostOrder',array('id'=>$vo.id))}'>退租</a>
							</if>
							|
							<a class='edit' href='{:url('rent/index',array('order_id'=>$vo.id,'order_into'=>1))}'>收租</a>
							|
							<a class='back_deposit' id="{$vo.id}" >退押金</a>
							|
							<a class='del' id="{$vo.id}">删除</a>
						</td>


					</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}<li class="active"><span>总{$count}条</span></li></div>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
<script>
	$(function(){
		stime="{$stime}";
		etime="{$etime}";
		cusname="{$cusname}";
		spacname="{$spacname}";
		commpany_name="{$commpany_name}";
		salesman="{$salesman}";
		if(spacname){
			$("input[name=space_name]").val(spacname);
		}
		if(salesman){
			$("input[name=salesname").val(salesman);
		}
		if(cusname){
			$("input[name=customer_name]").val(cusname);
		}
		//alert(commpany_name);
		if(commpany_name){
			$("input[name=commpany_name]").val(commpany_name);
		}
		if(stime){
			$("input[name=start_time]").val(stime);
		}
		if(etime){
			$("input[name=end_time]").val(etime);
		}
	})
	$(".back_deposit").click(function(){
		id=$(this).attr("id");
			if(confirm("是否确定退还押金？")){
				 $.post("{:url('Order/backDeposit')}",{id:id},function(data,status){
				 	alert('押金退还成功');	
				 	//$("input[name=deposit_price]").val('0.00');
				 	location.href="{:url('index')}";
				 })
			}
		
		   })	
	$(".del").click(
	    function(){
	    if(confirm("确认要删除吗")){
	    	    var id=$(this).attr("id");
	    	    $.post("{:url('delOrder')}",
	    		{id:id},
	    		function(data,status){

	    			location.href="{:url('index')}";
	    		});
	    }
		
		
	    }
	);



</script>